﻿@using GoodMan.Infrastructure.Entities.Entity;
@using GoodMan.Infrastructure.Entities.Contract;
@using GoodMan.Tool.Framework;
@{
    ViewBag.Title = "快餐列表";
    Layout = "~/Areas/WorkSpace/Views/Shared/_CollegeAdminTemplete.cshtml";
    ItemListBox<Product> data = ViewBag.Data;
    string SearchKey = ViewBag.SearchKey;
    List<Business> businessList = ViewBag.Business;
}
    <link type="text/css" rel="Stylesheet" href="/content/css/select2.css" />
<div id="content-header">
    <h1>
        快餐</h1>
</div>
<div id="breadcrumb">
    <a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>
        首页</a> <a href="/workspace/CollegeAdmin/GeneralFastFoods" class="tip-bottom">商品管理</a> <a href="#" class="current">快餐</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <h5>
                        快餐列表</h5>
                </div>
                <div class="widget-content nopadding">
                    <form action="/workspace/CollegeAdmin/SearchFastFoods" method="post" class="form-horizontal">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td style="width: 30%">
                                <div class="control-group">
                                    <label class="control-label">
                                        商户名</label>
                                    <div class="controls">
                                        <select id="business" name="businessId" style="width: 170px">
                                        <option value="-1">全部</option>
                                        @{
                                            if (businessList != null && businessList.Count != 0)
                                            {
                                                string selectStr = " selected=\"selected\"";
                                                foreach (var item in businessList)
                                                {
                                                    if (item.Id == ViewBag.BusinessId)
                                                    {
                                                        selectStr = " selected=\"selected\"";
                                                    }
                                                    else
                                                    {
                                                        selectStr = "";
                                                    }
                                                        <option value="@item.Id" @selectStr>@item.Name</option>
                                                }

                                            }
                                        }
                                    </select>
                                    </div>
                                </div>
                            </td>
                            <td style="width: 30%">
                                <div class="control-group">
                                    <label class="control-label">
                                        快餐关键字</label>
                                    <div class="controls">
                                        <input type="text" value="@SearchKey" name="ProductKey" style="width: 80%" />
                                    </div>
                                </div>
                            </td>
                            <td style="width: 20%">
                                <div class="controls" style="margin-left: 30px;">
                                    <button type="submit" class="btn btn-primary">
                                        <i class="icon-search icon-white"></i>查询</button>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <table class="table table-bordered table-striped">
                                    <thead>
                                        <tr>
                                            <th width="10%">
                                                商户名
                                            </th>
                                            <th width="10%">
                                                名称
                                            </th>
                                            <th width="60%">
                                                配菜信息
                                            </th>
                                            <th width="10%">
                                                创建时间
                                            </th>
                                            <th width="10%">
                                                操作
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @{
                                            if (data != null && data.Data != null && data.Data.Any())
                                            {
                                                foreach (var item in data.Data)
                                                {
                                            <tr>
                                                <td style="vertical-align: middle">
                                                    @item.business.Name
                                                </td>
                                                <td style="vertical-align: middle">
                                                    <a href="../../Shop/FastFoodDetail?d=@item.Id" target="_blank" ><span title="@item.ProductName">@item.ProductName</span></a>
                                                </td>
                                                <td style="vertical-align: middle">
                                                    @{
                                                    CateringSet catering = item.Catering.ToObject<CateringSet>();
                                                    if (catering != null && catering.cateringList != null && catering.cateringList.Any())
                                                    {
                                                        foreach (var cItem in catering.cateringList)
                                                        {
                                                        <div>
                                                            @cItem.caterCategory&nbsp &nbsp;&nbsp：</div>
                                                        <div>
                                                            @{
                                                            if (cItem.cateringInfoList != null && cItem.cateringInfoList.Any())
                                                    {
                                                            foreach (var ciItem in cItem.cateringInfoList)
                                                            {
                                                                <span>菜名:<font color="#333399">@ciItem.caterName</font>&nbsp;&nbsp;价格:<font color="#ff0000">&yen;@ciItem.caterPrice</font>&nbsp;
                                                                    &nbsp;</span>
                                                            }
                                                            }
                                                            }
                                                        </div>
                                                        <hr />
                                                        }
                                                    }
                                                    }
                                                </td>
                                                <td style="vertical-align: middle">
                                                    <span title="@item.CreateDate">@item.CreateDate.ToShortDateString()</span>
                                                </td>
                                                <td class="center" style="vertical-align: middle">
                                                    <a href="/workspace/CollegeAdmin/GeneralFastFoodDetail?id=@item.Id&productkey=@SearchKey" class="btn btn-primary btn-mini" style="margin-top:10px">
                                                        编辑</a> <a href="/workspace/CollegeAdmin/DeleteFastFood?id=@item.Id&page=@data.CurrentPage&productkey=@SearchKey"   onclick="if (confirm('确认删除数据？删除后该数据无法恢复！')==true){return true;}else{return false;}"   class="btn btn-danger btn-mini"  style="margin-top:10px">
                                                            删除</a>
                                                </td>
                                            </tr>
                                                }
                                            }
                                            else
                                            {
                                            <tr>
                                                <td colspan="10" align="center">
                                                    无快餐数据，请添加
                                                </td>
                                            </tr>  
                                            }
                                        }
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                    </table>
                    </form>
                </div>
                @Html.Raw(data.PageItemSegment)
            </div>
        </div>
    </div>
</div>
@section tail{
    <script type="text/javascript" src="/scripts/select2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#likProduct').addClass('open');

            $('#likProduct').addClass('active'); 
            $('#business').each(function () {
                $(this).select2();
            });
        });
    </script>
}
